//本程序功能,开机默认功能:J1~J5为每3秒点一次，J6~J10,Jok为每秒15次,点击时点屏33毫秒，点击最小间隔为33毫秒
//开机后按一下按键后会停止所有点击，当再按一次时会再次开启上边点击方式

#define J1 16   //控制点击数字1的引脚,板子上的J1点击头，定义为arduino nano小板子上的D11引脚
#define J2 2    //控制点击数字2的引脚,板子上的J2点击头，定义为arduino nano小板子上的D2引脚
#define J3 3    //控制点击数字3的引脚,板子上的J3点击头，定义为arduino nano小板子上的D3引脚
#define J4 4    //控制点击数字4的引脚,板子上的J4点击头，定义为arduino nano小板子上的D4引脚
#define J5 5    //控制点击数字5的引脚,板子上的J5点击头，定义为arduino nano小板子上的D5引脚
#define J6 6    //控制点击数字6的引脚,板子上的J6点击头，定义为arduino nano小板子上的D6引脚
#define J7 7    //控制点击数字7的引脚,板子上的J7点击头，定义为arduino nano小板子上的D7引脚
#define J8 8    //控制点击数字8的引脚,板子上的J8点击头，定义为arduino nano小板子上的D8引脚
#define J9 9    //控制点击数字9的引脚,板子上的J9点击头，定义为arduino nano小板子上的D9引脚
#define J10 10  //控制点击数字0的引脚,板子上的J10点击头，定义为arduino nano小板子上的D10引脚
#define Jok 12  //控制点击输入密码完成后的确定的引脚,板子上的Jok点击头，定义为arduino nano小板子上的D12引脚

#define led   A1

#define touchTime   100    //点击屏的时间
void setup() {
  // put your setup code here, to run once:

  delay(100);
  //设置所有点击控制引脚为功能输出
  pinMode(A1, OUTPUT);   //设置板子上的控制LED的引脚为输出高低电平的功能，引脚输出高电平时板子上的LED灯会亮
  pinMode(J10, OUTPUT);       
  pinMode(J1, OUTPUT);    
  pinMode(J2, OUTPUT);    
  pinMode(J3, OUTPUT);    
  pinMode(J4, OUTPUT);    
  pinMode(J5, OUTPUT);    
  pinMode(J6, OUTPUT);    
  pinMode(J7, OUTPUT);    
  pinMode(J8, OUTPUT);    
  pinMode(J9, OUTPUT);    
  pinMode(Jok, OUTPUT); 
  delay(1);
  

digitalWrite(A1, HIGH);
  //初始化所有点击都为非点击状态
  digitalWrite(J10, HIGH);  
  digitalWrite(J1, HIGH); 
  digitalWrite(J2, HIGH); 
  digitalWrite(J3, HIGH); 
  digitalWrite(J4, HIGH); 
  digitalWrite(J5, HIGH); 
  digitalWrite(J6, HIGH); 
  digitalWrite(J7, HIGH); 
  digitalWrite(J8, HIGH); 
  digitalWrite(J9, HIGH); 
  digitalWrite(Jok, HIGH); 
  delay(1);
}

void touchAll()
{
  digitalWrite(J10, HIGH);  
  digitalWrite(J1, HIGH); 
  digitalWrite(J2, HIGH); 
  digitalWrite(J3, HIGH); 
  digitalWrite(J4, HIGH); 
  digitalWrite(J5, HIGH); 
  digitalWrite(J6, HIGH); 
  digitalWrite(J7, HIGH); 
  digitalWrite(J8, HIGH); 
  digitalWrite(J9, HIGH); 
  digitalWrite(Jok, HIGH); 
  delay(1);
  digitalWrite(J10, LOW);  
  digitalWrite(J1, LOW); 
  digitalWrite(J2, LOW); 
  digitalWrite(J3, LOW); 
  digitalWrite(J4, LOW); 
  digitalWrite(J5, LOW); 
  digitalWrite(J6, LOW); 
  digitalWrite(J7, LOW); 
  digitalWrite(J8, LOW); 
  digitalWrite(J9, LOW); 
  digitalWrite(Jok, LOW); 
  delay(touchTime);
  digitalWrite(J10, HIGH);  
  digitalWrite(J1, HIGH); 
  digitalWrite(J2, HIGH); 
  digitalWrite(J3, HIGH); 
  digitalWrite(J4, HIGH); 
  digitalWrite(J5, HIGH); 
  digitalWrite(J6, HIGH); 
  digitalWrite(J7, HIGH); 
  digitalWrite(J8, HIGH); 
  digitalWrite(J9, HIGH); 
  digitalWrite(Jok, HIGH); 
  delay(touchTime);
}


void loop() {
  // put your main code here, to run repeatedly:
digitalWrite(J1,HIGH);
for(int i = 0;i < 30;i++)
  {
    digitalWrite(A1, LOW); 
    touchAll();
//    digitalWrite(J1,HIGH);
//    delay(touchTime);
//    digitalWrite(J1,LOW); 
//    delay(touchTime);
//    digitalWrite(J1,HIGH);
    digitalWrite(A1, HIGH); 
    delay(300);

  }
// for(int i = 0;i < 180;i++)
for(int i = 0;i < 180;i++)
  {
    delay(1000);
  }

delay(touchTime);

}
